package com.google.code.sip.ucenter.web.admin.controller;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.google.code.sip.ucenter.service.MongoManager;

@Controller
public class MongoMaintainController {
	@Autowired
	private MongoManager mongoManager;

	@RequestMapping("/admin/mongo/upgrade.do")
	public ModelAndView upgrade() throws Exception {
		mongoManager.upgrade();
		return new ModelAndView("admin.index");
	}

	@RequestMapping("/admin/mongo/validate.do")
	public ModelAndView validate() throws Exception {
		Map<String, Object> model = new HashMap<String, Object>();
		model.put("dataerrors", mongoManager.validate());
		return new ModelAndView("admin.mongo.dataerrors", model);
	}

}
